package org.flexthinker.binding.ui.form.binding.flex
{
    import mx.utils.StringUtil;

    import org.flexthinker.binding.bean.UpdateStrategy;

    import org.flexthinker.binding.ui.form.binding.support.FieldBinder;

    import spark.components.supportClasses.Range;

     /**
     *  Binder implementation for all visual components extending <code>Range</code>,
      *  which expose a <code>value</code> property.
     * These components are Scroll Bars, Sliders, Volume Bar, Spinner.
     *
     * <code>DefaultFlexBinderFactory</code> automatically serves this <code>RangeBinder</code> for these components.
     *
     *  <code>RangeBinder</code> generates a <code>Binding</code> on the <code>value</code> property of the
     *  </code>component</code>. The <code>UpdateStrategy</code> is <code>READ_WRITE</code>.
     */
    public class RangeBinder extends FieldBinder
    {
        public function RangeBinder(component:Range, formProperty:String)
        {
            super(component, formProperty);
            if ( !component.hasOwnProperty("value"))
            {
                 throw new ArgumentError( StringUtil.substitute( "Could not use RangeBinder on {0}", component) );
            }
            super.componentProperty = "value";
            super.updateStrategy = UpdateStrategy.READ_WRITE;
        }
    }
}
